export const addProduceIntroduce = (editor) => {
    // ------------------------------------------------------------------------------------------------------------
    /*
      产品介绍图文组件
      这里是没使用后端接口渲染的
    */
      const newProduceIntroduce = (editor) => {
        const { Components } = editor;
        Components.addType('newProduceIntroduce', {
          model: {
            defaults: {
              name: 'newProduceIntroduce',
              droppable: false,
              attributes: { class: 'produceIntroduce-card-wrapper' },
              components: [
                {
                  type: 'div',
                  attributes: { class: 'produceIntroduce-card-wrapper' },
                  components: [
                    {
                      type: 'image',
                      attributes: {
                        src: 'https://cdn4.codesign.qq.com/prototypes/2023/08/03/xDP3923q32qn08ZwlKp03/apgsmrtqzvfi3x3v/5c2600c7572af1bf8847061f35b69b1c.png',
                      },
                    },
                    {
                      type: 'div',
                      attributes: { class: 'produceIntroduce-card-div' },
                      components: [
                        {
                          type: 'text',
                          attributes: { class: 'produceContent' },
                          content: 'Bentley Descartes三维图像处理软件'
                        },
                        {
                          type: 'div',
                          attributes: { class:'produceContent-div' },
                          components: [
                            {
                              type: 'text',
                              attributes: { class: 'more' },
                              content: '了解更多'
                            },
                            {
                              type: 'text',
                              attributes: { class: 'free' },
                              content: '免费试用'
                            }
                          ]
                        }
                      ]
                    },
                  ],
                },
              ],
              script() {
                var that = document.getElementById(this.attributes.id.value);
                that.getElementsByClassName('more')[0].onclick = function () { alert('了解更多') }
                that.getElementsByClassName('free')[0].onclick = function () { alert('免费试用') }
              },
              styles: `
            .produceIntroduce-card-wrapper {
              border: 1px solid lightgray;width: 200px;height: 200px;background-color:white;color:black
            }
            .produceIntroduce-card-wrapper img{
              width: 100%;height: 60%;
            }
            .produceContent {
              height: 30%;width: 100%;font-size: 10px;
            }
            .produceIntroduce-card-div{width: 100%;height: 40%;padding: 10px;}
              .produceContent-div{height: 30%;width: 100%;padding-right:5%;margin-top:10px;display: flex;flex-direction: row-reverse;height: 30%;}
              .more{border-radius: 5px;border: 1px solid lightgray;font-size: 10px;background-color: white;}
              .free{border-radius: 5px;margin-right: 10px;border: 1px solid lightgray;font-size: 10px;}
          `,
            },
          },
        });
      };
      newProduceIntroduce(editor);
      editor.BlockManager.add("produceIntroduce", {
        label: "产品单元",
        category: "产品中心组件",
        media:`<svg t="1720768913590" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="28122" width="30" height="30"><path d="M504.1 452.5c-18.3 0-36.5-4.1-50.7-10.1l-280.1-138c-18.3-10.1-30.4-24.4-30.4-40.6 0-16.2 10.2-32.5 30.4-42.6L455.4 77.1c16.2-8.1 34.5-12.2 54.8-12.2 18.3 0 36.5 4.1 50.7 10.1L841 213c18.3 10.1 30.4 24.4 30.4 40.6 0 16.2-10.1 32.5-30.4 42.6L558.9 440.3c-16.3 8.1-34.5 12.2-54.8 12.2zM193.6 261.7l280.1 138c8.1 4.1 18.3 6.1 30.4 6.1 12.2 0 24.4-2 32.5-6.1l284.1-144.1-280.1-138c-8.1-4.1-18.3-6.1-30.4-6.1-12.2 0-24.4 2-32.5 6.1L193.6 261.7z m253.6 696.1c-10.1 0-20.3-2-30.4-8.1L165.1 817.8c-30.4-14.2-52.8-46.7-52.8-73.1V391.6c0-24.4 18.3-42.6 44.6-42.6 10.1 0 20.3 2 30.4 8.1L437.1 489c30.4 14.2 52.8 46.7 52.8 73.1v353.1c0 24.4-18.3 42.6-42.7 42.6z m-10.1-48.7c2 2 4.1 2 6.1 2v-349c0-8.1-10.1-24.4-26.4-32.5L165.1 397.7c-2-2-4.1-2-6.1-2v349.1c0 8.1 10.2 24.4 26.4 32.5l251.7 131.8z m144.1 48.7c-24.4 0-42.6-18.3-42.6-42.6V562.1c0-26.4 22.3-58.9 52.8-73.1L841 357.1c10.1-4.1 20.3-8.1 30.4-8.1 24.4 0 42.6 18.3 42.6 42.6v353.1c0 26.4-22.3 58.9-52.8 73.1L611.6 949.7c-12.2 6.1-20.3 8.1-30.4 8.1z m280-560.1L611.6 529.6c-16.2 8.1-26.4 24.4-26.4 32.5v349.1c2 0 4.1-2 6.1-2l249.6-131.9c16.2-8.1 26.4-24.4 26.4-32.5V395.7c-2 0-4 2-6.1 2z m0 0" p-id="28123"></path></svg>`,
        select: true,
        content: { type: "newProduceIntroduce" },
      });
}